<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>demo</title>
</head>

<body>
    <script type="text/javascript">
        function count() {
            let sum = 1
            function increment() {
                sum += 1
            }
            return { sum, increment }
        }
        const { sum, increment } = count()
        console.log(sum);
        increment()
        increment()
        console.log(sum);
    </script>
</body>

</html>